package com.emperor.customer.app;

import java.util.Map;

import org.apache.log4j.Logger;

import com.emperor.core.app.App;
import com.emperor.core.app.AppConstant;
import com.emperor.core.app.AppCtrl;

public class CustomerAppCtrl implements AppCtrl {

	public static final String CUST_CTRL = "customer.ctrl";
	public static final String CUST_ENQ = "customer.enq";
	public static final String CUST_NEW = "customer.new";
	public static final String CUST_MGM = "customer.mgm";
	
	public static final String CUST_MSG = "customer.msg";
	public static final String CUST_ID = "customer.id";
	
	public static Logger log = Logger.getLogger(CustomerAppCtrl.class);
	
	@Override
	public void doProcess(Map<String, Object> params) {
		
		App app = null;
		if (params == null) {
			log.error("Param is null");
		} else if (params.get(AppConstant.ACTION).equals(CUST_NEW)) {
			app = new CustomerAppNew(params);
		} else if (params.get(AppConstant.ACTION).equals(CUST_MGM)) {
			app = new CustomerAppMgm(params);
		} else {
			app = new CustomerAppEnq(params);
		}
		
		if (app != null) {
			app.open();
		}
	}

}
